home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / BGI / HP95.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-11-04  |  7.0 KB  |  474 lines

  1. IDEAL
  2. %TITLE    "HP95: a BGI driver for your HP95LX"
  3. MODEL    TINY
  4. CODESEG
  5.  
  6. NCOLS = 240
  7. NROWS = 128
  8.  
  9. PROC    main    FAR
  10.     push    ds
  11.     push    cs
  12.     pop    ds
  13.     cld
  14.     push    bp
  15.     call    [disptable+si]
  16.     pop    bp
  17.     pop    ds
  18.     ret
  19. ENDP    main
  20.  
  21.     db    2bh, 2ah, 0, 0
  22.  
  23. PROC    emulate
  24. LABEL    bar
  25. LABEL    arc
  26. LABEL    pieslice
  27. LABEL    filledellipse
  28.     ret
  29.     dd    ?
  30. ENDP    emulate
  31.  
  32. PROC    none
  33. LABEL    reserved
  34. LABEL    palette
  35. LABEL    allpalette
  36.     ret
  37. ENDP    none
  38.  
  39. LABEL    disptable    WORD
  40.     dw    install
  41.     dw    init
  42.     dw    clear
  43.     dw    post
  44.     dw    move
  45.     dw    draw
  46.     dw    vect
  47.     dw    emulate
  48.     dw    bar
  49.     dw    patbar
  50.     dw    arc
  51.     dw    pieslice
  52.     dw    filledellipse
  53.     dw    palette
  54.     dw    allpalette
  55.     dw    color
  56.     dw    fillstyle
  57.     dw    linestyle
  58.     dw    textstyle
  59.     dw    text
  60.     dw    textsiz
  61.     dw    reserved
  62.     dw    floodfill
  63.     dw    getpixel
  64.     dw    putpixel
  65.     dw    bitmaputl
  66.     dw    getimage
  67.     dw    putimage
  68.     dw    setclip
  69.     dw    colorquery
  70.  
  71. curx    dw    0
  72. cury    dw    0
  73. textdir    db    0
  74. fillcolor    db    1
  75. drawcolor    db    1
  76.  
  77. PROC    setcolor
  78.     mov    al, [drawcolor]
  79.     mov    ah, 09h
  80.     int    5fh
  81.     ret
  82. ENDP    setcolor
  83.  
  84. PROC    install
  85.     ; function 0: INSTALL
  86.     ; al = subfunction
  87.     ;   0: perform init
  88.     ;   1: get maximum graphics mode in cl
  89.     ;   2: get string indentifying mode cl
  90.  
  91.     cmp    al, 1
  92.     jne    @@notgetmodes
  93.     mov    cx, 1
  94.     ret
  95. @@notgetmodes:
  96.     jb    @@install
  97.     push    cs
  98.     pop    es
  99.     lea    bx, [@@string]
  100.     ret
  101. @@string    db    16, 'HP95lx 240x128', 0
  102. @@install:
  103.     push    cs
  104.     pop    es
  105.     lea    bx, [@@mode]
  106.     clc
  107.     ret
  108. LABEL    @@mode
  109.     db    0
  110.     db    0
  111.     dw    NCOLS-1
  112.     dw    NROWS-1
  113.     dw    NCOLS-1
  114.     dw    NROWS-1
  115.     dw    4400            ; 4.4 inches wide
  116.     dw    1800            ; 1.8 inches high
  117.     dw    7500            ; that's (height/NCOLS)/(width/NROWS)
  118.     db    08h, 08h, 90h, 90h
  119. ENDP    install
  120.  
  121. PROC    init
  122.     ; function 1: INIT
  123.     ; es:bx is parameter table
  124.  
  125.     mov    ax, 20h
  126.     int    5fh
  127.     ret
  128. ENDP    init
  129.  
  130. PROC    clear
  131.     ; function 2: CLEAR
  132.     ; clear the current viewport
  133.  
  134.     mov    ax, 20h
  135.     int    5fh
  136.     ret
  137. ENDP    clear
  138.  
  139. PROC    post
  140.     ; function 3: POST
  141.     ; no comment except a silly line wasted to say nothing
  142.  
  143.     mov    ax, 07h
  144.     int    5fh
  145.     ret
  146. ENDP    post
  147.  
  148. PROC    move
  149.     ; function 4: MOVE
  150.     ; relocates to (ax, bx)
  151.  
  152.     mov    [curx], ax
  153.     mov    [cury], bx
  154.     ret
  155. ENDP    move
  156.  
  157. PROC    draw
  158.     ; function 5: DRAW
  159.     ; draws a line from
  160.     ; current position to (ax, bx),
  161.     ; setting current position to (ax, bx))
  162.  
  163.     push    ax bx
  164.     mov    cx, [curx]
  165.     mov    dx, [cury]
  166.     mov    ah, 08h
  167.     int    5fh
  168.     pop    dx cx
  169.     call    setcolor
  170.     mov    ah, 06h
  171.     int    5fh
  172. ENDP    draw
  173.  
  174. PROC    vect
  175.     ; function 6: DRAWLINE
  176.     ; draws a line
  177.     ; from (ax, bx) to (cx, dx)
  178.  
  179.     push    ax bx
  180.     mov    ah, 08h
  181.     int    5fh
  182.     call    setcolor
  183.     pop    dx cx
  184.     mov    ah, 06h
  185.     int    5fh
  186.     ret
  187. ENDP    vect
  188.  
  189. PROC    patbar
  190.     ; function 9: PATBAR
  191.     ; fills the rectangle at coordinates
  192.     ; (ax, cx) to (bx, dx)
  193.  
  194.     push    ax bx
  195.     mov    al, [fillcolor]
  196.     mov    ah, 09h
  197.     int    5fh
  198.     mov    ah, 08h
  199.     int    5fh
  200.     pop    dx cx
  201.     mov    ax, 0502h
  202.     int    5fh
  203.     ret
  204. ENDP    patbar
  205.  
  206. PROC    color
  207.     ; function f: COLOR
  208.     ; al is color
  209.     ; ah is fill color
  210.  
  211.     mov    [drawcolor], al
  212.     mov    [fillcolor], ah
  213.     ret
  214. ENDP    color
  215.  
  216. PROC    fillstyle
  217.     ; function 10: FILLSTYLE
  218.     ; al = pattern number
  219.     ; al = -1 means homemade pattern
  220.     ; al = 0 means black
  221.     ; al = 1 means white
  222.  
  223.     push    cs
  224.     pop    ds
  225.     or    al, al
  226.     js    @@homemade
  227.     cbw
  228.     mov    cl, 3
  229.     shl    ax, cl
  230.     mov    bx, ax
  231.     add    bx, OFFSET @@pattern
  232.     push    cs
  233.     pop    es
  234. @@homemade:
  235.     mov    di, bx
  236.     mov    ah, 01h
  237.     int    5fh
  238.     ret
  239. LABEL    @@pattern    QWORD
  240.     dq    00000000000000000h
  241.     dq    0FFFFFFFFFFFFFFFFh
  242.     dq    00000FFFF0000FFFFh
  243.     dq    08040201008040201h
  244.     dq    070381C0E0783C1E0h
  245.     dq    070381C0E0783C1E0h
  246.     dq    0E1C3870F1E3C78F0h
  247.     dq    04B962D5AB469D2A5h
  248.     dq    0888888FF888888FFh
  249.     dq    08142241818244281h
  250.     dq    033CC33CC33CC33CCh
  251.     dq    00008008000080080h
  252.     dq    00022008800220088h
  253. ENDP    fillstyle
  254.  
  255. PROC    linestyle
  256.     ; function 11: LINESTYLE
  257.     ; sets the line style to al
  258.     ; (4 predefined styles 0-3.)
  259.     ; if al >= 4, bx contains style
  260.     ; cx contains width
  261.  
  262.     cmp    al, 4
  263.     jge    @@homemade
  264.     cbw
  265.     shl    ax, 1
  266.     mov    si, ax
  267.     mov    bx, [@@linestyle+si]
  268. @@homemade:
  269.     mov    cx, bx
  270.     mov    ah, 0bh
  271.     int    5fh
  272.     ret
  273. @@linestyle    dw    0ffffh        ; 0: solid
  274.         dw    0cccch        ; 1: dotted
  275.         dw    0fc78h        ; 2: dash - dot
  276.         dw    0f8f8h        ; 3: dashes
  277. ENDP    linestyle
  278.  
  279. PROC    textstyle
  280.     ; function 12: TEXTSTYLE
  281.     ; sets the system font to direction ah (1 means vertical) 
  282.     ; on font # al
  283.     ; with (bx,cx) = font size (x,y)
  284.     ; returns the size in (bx,cx), as truncated downwards to a multiple of 8.
  285.  
  286.     mov    [textdir], ah
  287.     mov    bx, 6
  288.     mov    cx, 8
  289.     ret
  290. ENDP    textstyle
  291.  
  292. PROC    text
  293.     ; function 13: TEXT
  294.     ; writes a string using system 8x8 fonts
  295.     ; using current color
  296.     ; the string is at es:bx
  297.     ; its length in cx
  298.  
  299.     call    setcolor
  300.     mov    al, [textdir]
  301.     mov    di, bx
  302.     add    bx, cx
  303.     push    [WORD es:bx]
  304.     mov    [BYTE es:bx], 0        ; null-terminate
  305.     mov    cx, [curx]
  306.     mov    dx, [cury]
  307.     mov    ah, 0fh
  308.     int    5fh
  309.     pop    [WORD es:bx]        ; restore
  310.     ret
  311. ENDP    text
  312.  
  313. PROC    textsiz
  314.     ; function 14: GETTEXTSIZE
  315.     ; returns the size of the text at es:bx, length cx
  316.     ; in bx = width, cx = height
  317.  
  318.     mov    bx, cx
  319.     add    bx, cx            ; * 6
  320.     add    bx, cx
  321.     add    bx, bx
  322.     mov    cx, 6
  323.     ret
  324. ENDP    textsiz
  325.  
  326. PROC    floodfill
  327.     ; function 16: FLOODFILL
  328.     ; flood-fills the area at (ax, bx)
  329.     ; until border-color cl is reached.
  330.  
  331.     ret
  332. ENDP    floodfill
  333.     
  334. PROC    getpixel
  335.     ; function 17h: GETPIXEL
  336.     ; gets the color of the pixel
  337.     ; at (ax, bx)
  338.     ; returns the color in dl
  339.  
  340.     mov    cx, ax
  341.     mov    dx, bx
  342.     mov    ah, 12
  343.     int    5fh
  344.     mov    dl, al
  345.     ret
  346. ENDP    getpixel
  347.  
  348. PROC    putpixel
  349.     ; function 18: PUTPIXEL
  350.     ; writes a point of color dl
  351.     ; at (ax, bx)
  352.     ; returns nothing
  353.  
  354.     mov    cx, ax
  355.     mov    dx, bx
  356.     mov    ah, 7
  357.     int    5fh
  358.     ret
  359. ENDP    putpixel
  360.     
  361. PROC    bitmaputl
  362.     ; function 19: BUTMAPUTL
  363.     ; returns a pointer to the far procedure's dispatch table
  364.     ; in es:bx
  365.  
  366.     push    cs
  367.     pop    es
  368.     lea    bx, [@@dispfar]
  369.     ret
  370. LABEL    @@dispfar    WORD
  371.     dw    $$exit
  372.     dw    $$exit
  373.     dw    putpixel
  374.     dw    getpixel
  375.     dw    $$getpixelwidth
  376.     dw    $$exit
  377.     dw    $$exit
  378.     dw    $$setwritemode
  379.  
  380. PROC    $$exit    FAR
  381.     ret
  382. ENDP    $$exit
  383.  
  384. PROC    $$getpixelwidth    FAR
  385.     mov    ax, 1
  386.     ret
  387. ENDP    $$getpixelwidth
  388.  
  389. PROC    $$setwritemode    FAR
  390.     or    ax, ax
  391.     mov    ax, 0a00h
  392.     jz    @@put
  393.     add    ax, 3
  394. @@put:
  395.     int    5fh
  396.     ret
  397. ENDP    $$setwritemode
  398.  
  399. ENDP    bitmaputl
  400.     
  401. PROC    getimage
  402.     ; function 1a: GETIMAGE
  403.     ; [es:bx] is image to read
  404.     ; at (cx, dx)
  405.  
  406.     push    [es:bx-2]
  407.     push    [es:bx-4]
  408.     lea    di, [bx-4]
  409.     mov    si, [es:bx]
  410.     mov    bp, [es:bx+2]
  411.     add    si, cx
  412.     add    bp, dx
  413.     mov    ah, 0dh
  414.     int    5fh
  415.     pop    [es:bx-4]
  416.     pop    [es:bx-2]
  417.     ret
  418. ENDP    getimage
  419.         
  420. PROC    putimage
  421.     ; function 1b: PUTIMAGE
  422.     ; displays the [es:bx]
  423.     ; at (cx, dx)
  424.     ; with mode al
  425.  
  426.     push    [es:bx-2]
  427.     push    [es:bx-4]
  428.     lea    di, [es:bx-4]
  429.     mov    [WORD es:di], 1
  430.     mov    [WORD es:di+2], 1
  431.     test    al, 1
  432.     jz    @@skip
  433.     xor    al, 2            ; swap AND and XOR modes
  434. @@skip:
  435.     mov    ah, 0eh
  436.     int    5fh
  437.     pop    [es:bx-4]
  438.     pop    [es:bx-2]
  439.     ret
  440. ENDP    putimage
  441.     
  442. PROC    setclip
  443.     ; function 1c: SETLIMITS
  444.     ; (ax, bx), (cx, dx) are limits
  445.  
  446.     mov    si, cx
  447.     mov    di, dx
  448.     mov    cx, ax
  449.     mov    dx, bx
  450.     mov    ah, 04h
  451.     int    5fh
  452.     ret
  453. ENDP    setclip
  454.     
  455. PROC    colorquery
  456.     ; function COLOR_QUERY:
  457.     ; al = 0: color table size
  458.     ;    = 1: default color table
  459.  
  460.     or    al, al
  461.     jne    @@next
  462.     mov    bx, 2
  463.     mov    cx, 1
  464.     ret
  465. @@next:
  466.     push    cs
  467.     pop    es
  468.     lea    bx, [@@colordata]
  469.     ret
  470. @@colordata    db    0        ; no entry
  471. ENDP    colorquery
  472.  
  473. END    main
  474.